package com.atguigu.day03;

import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * @author Felix
 * @date 2024/4/1
 * 该案例演示了执行环境的创建
 */
public class Flink01_Env {
    public static void main(String[] args) throws Exception {
        //指定流处理环境
        //TODO 创建本地执行环境:仅在开发时候用
        //LocalStreamEnvironment env = StreamExecutionEnvironment.createLocalEnvironment();
        //TODO 创建本地执行环境:仅在开发时候用   带webUI，需要在pom.xml中添加flink-rumtime-web依赖
        //Configuration conf = new Configuration();
        //conf.set(RestOptions.PORT,8088);
        //StreamExecutionEnvironment env = StreamExecutionEnvironment.createLocalEnvironmentWithWebUI(conf);

        //TODO 根据实际运行情况，自动创建流处理环境
        //StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        //TODO 创建远程执行环境
        StreamExecutionEnvironment env = StreamExecutionEnvironment.createRemoteEnvironment("hadoop102", 8081, "D:\\dev\\workspace\\bigdata-1030\\target\\bigdata-1030-1.0-SNAPSHOT.jar");

        //TODO 从指定的文件中读取数据
        DataStreamSource<String> wordDS = env.readTextFile("/opt/module/flink-1.17.0/word.txt");

        wordDS.print();

        env.execute();
    }
}
